home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / internet misc / XML PalmPilot applications 1.0 / XTPP-latest.exe / Pilot / details.xst < prev    next >
Encoding:
Text File  |  1999-12-17  |  6.4 KB  |  258 lines

  1. <XST Filename='details.xst'
  2.      Description='Output single address from Pilot database to HTML or Plaintext.  Returns the first record from the addressbook matching either the given first name or surname'
  3.      Author='David Ball/Philip Allen'
  4.      Version='2.0'
  5.      Date='12 April 1999'
  6.      Copyright='&copy; 1999 DecisionSoft Limited'
  7.      XMLscript='1.0'
  8.      Ref='details'
  9.      debug=''
  10.      __maxCR="2"
  11. ><_if test=" \ENV\REQUEST_METHOD.__exists" >Content-type: text/html
  12.  
  13. </_if>
  14.  
  15. <!--
  16.     We need the "Content-type: text/html" to be on the first output 
  17.     line followed by two carriage returns, if we're running in cgi
  18.  
  19.     Note the 'double backslash' used instead of the single backslash.  
  20.     Always use double backslash when describing DOS/Windows directory 
  21.     paths.
  22. -->
  23.  
  24. <!--
  25.     YOU NEED TO CONFIGURE THESE
  26. -->
  27.     # $\.appsRoot := "..\\pilot\\" #
  28.     # $\.datName := "sample.dat" #
  29.  
  30. <!--
  31.     If we're coming in from the command line, arguments with spaces in 
  32.     will have quotes around them (because DOS batch files are lame), 
  33.     which we don't want.  So we need to get rid of them...
  34. -->
  35.  
  36. <_if test="\ENV\FIRSTNAME.__exists">
  37.     <then>
  38.     <barney __mode="hide">
  39.     <fred __maxCR="0"><_filter find='\"' replace=''># \ENV\FIRSTNAME #</_filter></fred>
  40.     </barney>
  41.     # \ENV\FIRSTNAME := $barney\fred #
  42.     </then>
  43. </_if>
  44.  
  45. <_if test="not( \CGI\surname.__exists) and (\ENV\SURNAME.__exists)">
  46.     # \CGI\surname := \ENV\SURNAME #
  47. </_if>
  48.  
  49. <_if test="not( \CGI\firstname.__exists) and (\ENV\FIRSTNAME.__exists)">
  50.     # \CGI\firstname := \ENV\FIRSTNAME #
  51. </_if>
  52.  
  53. <_if test=" \ENV\REQUEST_METHOD.__exists" >
  54.     <then> # $\.context := "cgi" # </then>
  55.     <else> # $\.context := "cmdline" # </else>
  56. </_if>
  57.  
  58. <_if test="0">
  59.  
  60. <!--
  61.     Defaults used for debugging CGI operation
  62. -->
  63.     # \CGI\surname := "Clinton" #
  64.     # \CGI\firstname := "William" #
  65.     # $\.context := "cgi" #
  66.     # $\.fileOut := "1" #
  67. </_if>
  68.  
  69. # \.context := $\.context #
  70.  
  71. <!--
  72.     Set global attributes
  73. -->
  74.  
  75. # $.cellColor := "yellow" #
  76. # $.mainColor := "lightblue" #
  77.  
  78. <!--
  79.     Define the system command
  80. -->
  81.  
  82. # $\.cmd := $\.appsRoot 'loadbook ' $\.appsRoot $\.datName #
  83. # $\.sysCmd := $\.cmd '>  c:\\temp\\CGItmp.txt' #
  84.  
  85. <!--
  86.     The system command is piped to file to make it work with httpd.
  87. -->
  88.  
  89. <_eval result="data">
  90. <_filter find='\#' replace='' >
  91.     <Pilot >
  92.         <_system command="# $\.sysCmd #"/>
  93.         <_echo file="c:\temp\CGItmp.txt" />
  94.     </Pilot>
  95. </_filter>
  96. </_eval>
  97.  
  98. <_if >
  99.     Debug information: incoming data -# \Pilot #-
  100. </_if>
  101.  
  102. <!--
  103.     Define the templates we're going to run
  104. -->
  105.  
  106. <_template name="DisplayOneHTML" >
  107. <_foreach object="AddressRecord" >
  108. <_if test="not( \CGI\surname.__exists) and (not( \CGI\firstname.__exists) or (\CGI\firstname == FirstName))">
  109.     # \CGI\surname := LastName #
  110. </_if>
  111. <_if test="not( \CGI\firstname.__exists) and (\CGI\surname == LastName)">
  112.     # \CGI\firstname := FirstName #
  113. </_if>
  114. <_if test="(LastName == \CGI\surname) and (FirstName == \CGI\firstname)"><then>
  115.     <HTML>
  116.     <HEAD>
  117.     <TITLE>XML address display</TITLE>
  118.     </HEAD>
  119.     <BODY BGCOLOR="ffffff">
  120.     <CENTER>
  121.     <TABLE CELLPADDING="10">
  122.  
  123.         <TR>
  124.             <TD ALIGN="left" VALIGN="bottom">
  125.                 <IMG SRC="images/xmlscript.jpg" ALT="XML Script" />
  126.             </TD>
  127.             
  128.             <TD BGCOLOR="#$.mainColor#" ALIGN="center">
  129.  
  130.                 <TABLE CELLPADDING="5">
  131.  
  132.                     <TR>
  133.                         <TD ALIGN="left" VALIGN="top"><B>Name</B></TD>
  134.                         <TD BGCOLOR="# $.cellColor #">#FirstName# #LastName#</TD>
  135.                     </TR>
  136.                     <TR>
  137.                         <TD ALIGN="left" VALIGN="top"><B>Title</B></TD>
  138.                         <TD BGCOLOR="#$.cellColor#">#Title#</TD>
  139.                     </TR>
  140.                     <TR>
  141.                         <TD ALIGN="left" VALIGN="top"><B>Address</B></TD>
  142.                         <TD BGCOLOR="#$.cellColor#">#Address#<BR />
  143.                             #City# #State#  #Zipcode#</TD>
  144.                     </TR>
  145.                     <TR>
  146.                         <TD ALIGN="left" VALIGN="top"><B>Email</B></TD>
  147.                         <TD BGCOLOR="#$.cellColor#"><A HREF="#'mailto:' Email#">#Email#</A></TD>
  148.                     </TR>
  149.                     <TR>
  150.                         <TD ALIGN="left" VALIGN="top"><B>Work</B></TD>
  151.                         <TD BGCOLOR="#$.cellColor#">#Phone#</TD>
  152.                     </TR>
  153.                     <TR>
  154.                         <TD ALIGN="left" VALIGN="top"><B>Home</B></TD>
  155.                         <TD BGCOLOR="#$.cellColor#">#Home#</TD>
  156.                     </TR>
  157.                     <TR>
  158.                         <TD ALIGN="left" VALIGN="top"><B>Fax</B></TD>
  159.                         <TD BGCOLOR="#$.cellColor#">#Fax#</TD>
  160.                     </TR>
  161.                 </TABLE>
  162.             </TD>
  163.         </TR>
  164.     </TABLE>
  165.     </CENTER>
  166.     </BODY>
  167.     </HTML>
  168. </then>
  169. </_if>
  170. </_foreach>
  171.  
  172. </_template>
  173.  
  174. <_template name="DisplayOnePlain">
  175. <_foreach object="AddressRecord" >
  176. <_if test="not( \CGI\surname.__exists) and (not( \CGI\firstname.__exists) or (\CGI\firstname == FirstName))">
  177.     # \CGI\surname := LastName #
  178. </_if>
  179. <_if test="not( \CGI\firstname.__exists) and (\CGI\surname == LastName)">
  180.     # \CGI\firstname := FirstName #
  181. </_if>
  182. <_if test="(LastName == \CGI\surname) and (FirstName == \CGI\firstname)">
  183.  
  184. XML address display
  185.  
  186. Name:    #FirstName# #LastName#
  187. Title:   #Title#
  188. Address: #Address#
  189.          #City# #State# #Zipcode#
  190. Email:   #Email#
  191. Work:    #Phone#
  192. Home:    #Home#
  193. Fax:     #Fax#
  194.  
  195. </_if>
  196. </_foreach>
  197. </_template>
  198.  
  199.  
  200. <!--
  201.     Tie the template to the data
  202. -->
  203.  
  204. <_method object="Pilot" template="DisplayOneHTML" context="cgi" />
  205. <_method object="Pilot" template="DisplayOnePlain" context="cmdline" />
  206.  
  207. <!--
  208.     Process the data
  209. -->
  210. <_if test="$\.fileOut">
  211.     <then>
  212.         <_output 
  213.             type="file" 
  214.             mode="replace" 
  215.             name="# '../output/' $\.Ref '.out' #" 
  216.             __maxCR="1"><_process object="\Pilot" /></_output>
  217.         <_output 
  218.             type="file" 
  219.             mode="replace" 
  220.             name="# '../output/' $\.Ref '.dif' #" 
  221.             __maxCR="1">
  222.             <_system __maxCR="1" command="# 'diffHtml.bat ' $\.Ref #" /></_output>
  223.     </then>
  224.     <else>
  225.         <_if test="((\CGI\surname.__exists) 
  226.                 and (\CGI\firstname.__exists) 
  227.                 and not( \Pilot\AddressRecord{( LastName == \CGI\surname ) 
  228.                 and ( FirstName == \CGI\firstname )})) 
  229.                 or ((\CGI\surname.__exists) and not( \CGI\firstname.__exists) 
  230.                 and not( \Pilot\AddressRecord{( LastName == \CGI\surname)})) 
  231.                 or (not( \CGI\surname.__exists) and (\CGI\firstname.__exists) 
  232.                 and not( \Pilot\AddressRecord{( FirstName == \CGI\firstname)}))">
  233.             <then>
  234.                 <_if test="$.context == 'cgi'">
  235.                     <then>
  236.                         <HTML>
  237.                         <HEAD>
  238.                         <TITLE>XML address display</TITLE>
  239.                         </HEAD>
  240.                         <BODY BGCOLOR="ffffff">
  241.                         <H1 ALIGN="Left">No Matches Found</H1>
  242.                         </BODY>
  243.                         </HTML>
  244.                     </then>
  245.                     <else>
  246. No Matches found.
  247.                     </else>
  248.                 </_if>
  249.             </then>
  250.             <else>
  251.                 <_process object="\Pilot" />
  252.             </else>
  253.         </_if>
  254.     </else>
  255. </_if>
  256.  
  257. </XST>
  258.